package com.example.demo.mapper;

import com.example.demo.entity.Employee;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface EmployeeMapper {
    @Select("SELECT * FROM employee WHERE id = #{id}")
    @Results({
        @Result(property = "id", column = "id"),
        @Result(property = "department", column = "department_id", 
                one = @One(select = "com.example.demo.mapper.DepartmentMapper.getDepartmentById"))
    })
    Employee getEmployeeById(Integer id);

    @Select("SELECT * FROM employee WHERE department_id = #{departmentId}")
    List<Employee> getEmployeesByDepartmentId(Integer departmentId);
}